/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bgu.ppm.dat.view;

/**
 *
 * @author User
 */
public class SelecteableItem<T> {

    private boolean canEditText = true;
    private boolean selected = false;
    private T item;

    public SelecteableItem(T item, boolean canEditText) {
        this.item = item;
        this.canEditText = canEditText;
    }

    public boolean isCanEditText() {
        return canEditText;
    }
    
    public boolean isSelected() {
        return selected;
    }

    public void setSelected(boolean selected) {
        this.selected = selected;
    }

    public void flipSelected() {
        setSelected(!isSelected());
    }

    public T getItem() {
        return item;
    }

    @Override
    public String toString() {
        return "" + item;
    }

    public void setFromText(String text) {
        if (item instanceof String) {
            item = (T) text;
        } else {
            throw new UnsupportedOperationException("Not Implemented Yet.");
        }
    }
}
